package com.zn.opit.videoframe.config;

import io.minio.MinioClient;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MinIo客户端配置
 */
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "spring.minio")
public class ExtMinioClientConfig {

    private String endpoint;
    private String accessKey;
    private String secretKey;
    private String bucketName;
    private String allowFileType; // 允许上传的文件类型
    private Integer chunkUploadExpirySecond; // 分片上传有效期（单位：秒）

    @Bean
    public MinioClient minioClient() {
        MinioClient minioClient = MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
        return new ExtMinioClient(minioClient);
    }
}
